import http from "@/utils/http";


/**
 * 获得子分类
 * @returns
 */
export function getChildNameAPI() {
    return http.get(`/category/getChild`);
}

/**
 * 获取所有分类
 * @returns
 */
export function getCategoryAPI(params) {
    return http.post(`/category/getByConditions`,params);
}

/**
 * 获得父分类
 * @returns
 */
export function getParentNameAPI() {
    return http.get(`/category/getParent`);
}

/**
 * 添加分类
 * @param {object} params Category
 * @param {string} params.parentId
 * @param {string} params.name
 * @returns
 */
export function addCategoryAPI(params) {
    return http.post(`/category/add`, params);
}

/**
 * 删除分类
 * @param {string} id
 * @returns
 */
export function deleteCategoryAPI(id) {
    return http.delete(`/category/${id}`);
}

/**
 * 更新分类
 * @param {object} params Category
 * @param {number} params.id
 * @param {number} params.parentId
 * @param {string} params.name
 * @returns
 */
export function updateCategoryAPI(params) {
    return http.post(`/category/update`, params);
}